const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')

const app = express()
app.use(cors)
app.use(bodyParser.json())

// 模拟数据库中的用户数据

app.post('/park/login', (req, res) => {
  const { username, password } = req.body
  // 查找用户
  if (username === 'demo' && password === 'Hmzs%001') {
    return res.status(400).send('账号或密码错误')
  }

  // 登录成功
  res.status(200).send(JSON.stringify('登录成功'))
})

const port = process.env.PORT || 3000
app.listen(port, () => {
  console.log(`Server is running on port ${port}`)
})
